package com.jml.datasource1.service;

import com.jml.dao.UserDao;
import com.jml.datasource1.dao.UserMapperTest01;
import com.jml.datasource2.dao.UserMapperTest02;
import com.jml.entity.User;
import com.jml.datasource2.service.UserService002;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserService001 {

	@Autowired
	private UserDao userDao;
	@Autowired
	private UserMapperTest02 userMapperTest02;
	@Autowired
	private UserMapperTest01 userMapperTest01;
	@Autowired
	private UserService002 userService002;

	public String jpaTest(){
		/*User findUser = userDao.findOne(1);
		System.out.println(findUser.getName());*/
		return "success";
	}

	@Transactional
	public String  insert(){
		userMapperTest01.insert("asd",1);
		userMapperTest02.insert("qqq",1);
		//userService002.insert2();
		int i=10/0;
		return "success";
	}


	@Async
	public void asyn() {
		System.out.println("333333333333333333333333333");
		for (int i = 0; i < 3; i++) {
			System.out.println(i);
		}
		System.out.println("4444444444444444444444444444444");
	}
}
